package api

import (
    "github.com/astaxie/session"
    _ "github.com/astaxie/session/providers/memory"
    "net/http"
)

const (
    pwdPrefix = "qS64XZ98fty$#@*532"
)

type Params struct {
    Username string `json:"username"`
    Password string `json:"password"`
}

type Result struct {
    Code    int
    Message string
    Data    any
}

var globalSession *session.Manager

func init() {
    globalSession, _ = session.NewManager("memory", "gosessionid", 3600)
    go globalSession.GC()
}

func Api() {
    http.HandleFunc("/user/login", login)
    err := http.ListenAndServe("0.0.0.0:8080", nil)
    if err != nil {
        return
    }
}
